home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
pascal
/
pulldw.zip
/
XPULLDW.PAS
< prev
Wrap
Pascal/Delphi Source File
|
1987-12-04
|
5KB
|
151 lines
{
xpulldw.pas -
a demonstration program using the pulldown.tpu unit
}
program xpulldw;
uses dos,crt,pulldown;
{$V-}
{
A pulldown menu system consists of a horizontal bar menu of n choices,
and from 1 to n associated vertical submenus. The top (or bar) menu may
have up to 80 characters; each submenu may have up to 255 (see note below
for submenus with more than 128 characters).
To define a menu, simply declare a typed constant string to represent
the top menu. The choices in the menu are demarcated with '|'.
Then declare typed constants for the submenus in the appropriate order.
Null submenus (e.g., the 'Edit' choice from the Turbo Pascal main menu)
are indicated with a string[1] = ' '. The example below should make
everything clear.
It may be worthwhile to examine the code in pulldown.pas. I contains
useful general-purpose procedures for windowing and screen accessing.
}
const
{
Here the menus are defined. The maximum lengths of the strings must be
EXACTLY equal to the actual lengths of the defined constants. A simple way
to get it right is to write them as shown below, then place the editor's
cursor under the ultimate character of the string. The length will be
the 'Col' number reported on the editor's status line minus 1.
Note that Turbo Pascal forbids the declaration of string constants longer
than 128 characters, although the maximum length of the typed constant may
be declared to be 255. If you have a long sub-menu (say,200 chars ),
try the following: declare the constant s as string[200], but initialize
only the first 128 or less characters; declare another constant which will
contain the remaining characters; concatenate the second one to the first
before invoving the menu procedure.
const
s : str200 = '....100 chars...';
.
.
.
rest: str100 = '...the remaining 100 chars...';
.
.
.
begin
.
.
s:=s+rest;
menu(1,s,.......);
.
.
.
end;
This has the unfortunate side-effect of wasting 100 bytes, but it works.
}
menTop : string[52] = { the top bar menu }
'Database|Files|Update|Calculate|Report|Globals|Tools';
men1 : string[36]= { goes under 'Database' }
' Retrieve | Save | Put Away | Erase ';
men2 : string[76]= { goes under 'Files' }
' Choose File | Browse Fields | Index | Filters | Add File | Modify Structure ';
men3 : string[31]= { goes under 'Update' }
' Browse | Find | Search | List ';
men4 : string[1] = { goes under 'Calculate'}
' ';
men5 : string[55]= { goes under 'Report' }
' Create Report | Modify Report Format | Print a Report ';
men6 : string[18]= { goes under 'Globals' }
' Printer | Status ';
men7 : string[35] = { goes under 'Tools' }
' Directory | Op. System | Chg. Dir ';
procedure msg(s:string); { an all-purpose job for each
menu choice
}
begin
makewindow(2,20,10,20,7,textattr,'Pulldown Result');
writeln;
writeln('Main Choice: ',choice);
writeln('Sub-Choice: ',choice2);
writeln(s);
writeln;
write('Press Enter'); readln;
closewindow(2);
end;
begin
checkbreak:=FALSE;
{ choice and choice2 are globals defined in pulldown.tpu }
repeat
pulldownmenu(menTop,choice,choice2,choice,choice2);
case choice of
0 : msg('Quit');
1 : case choice2 of
1 : msg('Retreive a DB');
2 : msg('Save a DB');
3 : msg('Put away DB');
4 : msg('Erase a DB');
end;
2 : case choice2 of
1 : msg('Choose a file');
2 : msg('Set Browse fields');
3 : msg('Choose index');
4 : msg('Set filter');
end;
3 : case choice2 of
1 : msg('Browse records');
2 : msg('Find a record');
3 : msg('Search for a string');
4 : msg('List index');
end;
4 : msg('Calculate...');
5 : msg('Report menu...');
6 : case choice2 of
1 : msg('Set printer codes');
2 : msg('Get status data');
end;
7 : case choice2 of
1 : msg('Display directory');
2 : msg('Operating system');
3 : msg('Change working directory');
end;
end;
until choice = 0;
end.